package object4.package6;
//Comparable是拿着this和参数o作比较
//Comparator是拿着两个参数作比较
import java.util.Comparator;
public class StudentComparator implements Comparator<Student2>{

    public int compare(Student2 o1,Student2 o2) {
        //o1<o2,返回小于0的整数
        //o1>o2,返回大于0的整数
        //o1=o2,返回等于0的整数
        if(o1.getScore() < o2.getScore()){
            return -1;
        }
        if(o1.getScore() > o2.getScore()){
            return 1;
        }
        if(o1.getId() > o2.getId()){
            return -1;
        }
        if(o1.getId() < o2.getId()){
            return 1;
        }
        return 0;
    }
}

